 //
//  UIBarButtonItem+Extension.m
//  SINA
//
//  Created by 王相超 on 16/3/28.
//  Copyright © 2016年 chuanzhi. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

+(instancetype)itemWithImageName:(NSString *)imageName target:(id)target action: (SEL)action{
    
    UIButton *button = [[UIButton alloc] init];
    
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]] forState:UIControlStateHighlighted];
    
    button.size = button.currentImage.size;
    
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc] initWithCustomView:button];
    
}

+(instancetype)itemWithImageName:(NSString *)imageName title:(NSString *)title target:(id)target action: (SEL)action{
    
    
    UIButton *button = [[UIButton alloc] init];
    
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]] forState:UIControlStateHighlighted];
    
    button.size = button.currentImage.size;
    
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
    [button setTitleColor:RGB(53,53,53) forState:UIControlStateNormal];
    
    
    
    
    
    return [[UIBarButtonItem alloc] initWithCustomView:button];
    
    
    
    
    
}








@end
